<?php

namespace myshop\common\middleware;

use longhu\base\AdminBaseRequest as Request;
use think\facade\Config;
use think\Middleware;

/**
 * 权限
 */
class AdminAuthMiddleware extends Middleware
{
    public function handle($request, \Closure $next)
    {
        $token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
        if (empty($token)) {
            $token = trim(ltrim($request->get('x-token')));
        }
        $user = [];
        $jwtAuth = app('jwt')->checkToken('sys',$token);
        dump($jwtAuth);exit;
        Request::macro('adminId', function () use (&$user) {
            return $user['id']??1;
        });

        return $next($request);
    }
}